{include file="public/head"/}
<link rel="stylesheet" href="__LAYADMIN__/style/template.css" media="all">
<style>
    .cmdlist-container{border: 1px solid #ececec;text-align: center;box-shadow: 0 5px 10px rgba(0, 0, 0, 0.1);}
    .cmdlist-container .img-box{height: 200px;line-height:200px;border-bottom: 1px solid #eeecec;}
    .clt-atta{width: 200px;float:left;}
    .cmdlist-container img{width: auto;max-width: 100%;display: inline-block; vertical-align: middle;cursor: pointer;}
    .pagination{padding: 0!important;}
    .pagination li{list-style-type: none;float: left;display: inline-block;border: 1px solid #e2e2e2;}
    .pagination li a{display: inline-block;padding: 8px 12px;width: 100%;height: 100%;}
    .pagination li span{display: inline-block;padding: 8px 12px;width: 100%;height: 100%;}
    .pagination .disabled{color: #d2d2d2!important;cursor: not-allowed!important;}
    .pagination .active{background-color: #009688;color: #fff;}
    .clearfix{clear: both;}
</style>
{include file="public/foot"/}
<div class="layui-fluid layadmin-cmdlist-fluid">
    <div class="layui-card">
        <div class="layui-card-header">资源列表</div>
        <div class="layui-card-body">
            <div class="clt-auth-btns" style="margin-bottom: 10px;">
                <button class="layui-btn layui-btn-danger" id="direct" data-type="direct" onmouseover="layer.tips('清除调用0次的图片','#direct');">清除空闲图片</button>
            </div>
            <div class="layui-row layui-col-space30">
                {volist name='list' id="vo"}
                <div class="clt-atta">
                    <div class="cmdlist-container">
                        <a href="{$vo.url}" target="_blank">
                        <div class="img-box" onmouseover="layer.tips('点击查看图片',this,{tips: [1, '#000']});" onmouseout="layer.closeAll();">
                            <img id="img{$vo.id}" src="{$vo.url}">
                        </div>
                        </a>
                        <div class="cmdlist-text" style="text-align: center;">
                            <div>调用：{$vo.count}次</div>
                            <div>
                                <button type="button" class="layui-btn" id="pic{$vo.id}">
                                    <i class="layui-icon">&#xe67c;</i>替换图片
                                </button>
                            </div>
                        </div>
                    </div>
                </div>
                <script>
                    layui.use('upload', function () {
                        var upload = layui.upload,$= layui.$;
                        upload.render({
                            elem: '#pic{$vo.id}',
                            url: '{:url("admin/attachment/upload",["id"=>$vo.id])}',
                            title: '上传图片',
                            accept:'images',
                            done: function (res) {
                                layer.msg(res.msg, {icon: 1, time: 1000}, function () {
                                    $('#img{$vo.id}').attr('src',res.url);
                                });
                            }
                        })
                    })
                </script>
                {/volist}
                <div style="clear: both;"></div>
                <div>{$page|raw}</div>
                <div class="clearfix"></div>
            </div>
        </div>
    </div>
</div>
<script>
    layui.config({
        base: '__LAYADMIN__/',{if config('app.app_debug')}version: true{/if}
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index','attachment']);
</script>
</body>
</html>